package cn.tedu.boot041.controller;

import cn.tedu.boot041.entity.Person;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BMIController {
    @RequestMapping("/postBmi")
    public String postBmi(@RequestBody Person person){
        double bmi = person.getW()/( person.getH()* person.getH());
        if(bmi<18.5){
            return bmi+"偏瘦";
        }
        if(bmi<24){
            return bmi+"健康";
        }
        if(bmi<28){
            return bmi+"微胖";
        }
        return bmi+"太胖了";
    }
    @RequestMapping("/bmi")
    public String postBmi(double h,double w){
        double bmi = w/(h*h);
        if(bmi<18.5){
            return "偏瘦";
        }
        if(bmi<24){
            return "健康";
        }
        if(bmi<28){
            return "微胖";
        }
        return "太胖了";
    }
}
